package com.zj.photoTest;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import com.zj.album.graphy.PhotoTemporaryCache;
import com.zj.album.graphy.activity.PhotoGraphActivity;
import com.zj.album.graphy.module.PhotoInfo;

import java.util.List;

/**
 * Creat by zhaojie on 2017-12-21.
 * <p>
 * 意见反馈
 */

public class MainActivity extends AppCompatActivity {

    private TextView tvChoose;
    private Button btnGo;
    private final String cacheNameCode = "photoTest";

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        btnGo = (Button) findViewById(R.id.main_btn_go);
        tvChoose = (TextView) findViewById(R.id.main_tv_choose);
        btnGo.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                gotoGraph();
            }
        });
    }

    @Override
    protected void onResume() {
        super.onResume();
        if (tvChoose != null) {
            List<PhotoInfo> infos = PhotoTemporaryCache.getCacheImages(cacheNameCode);
            if (infos != null) {
                StringBuffer sb = new StringBuffer();
                for (PhotoInfo info : infos) {
                    sb.append(info.uri + "\n\n");
                }
                tvChoose.setText(sb.toString());
            }
        }
    }

    private void gotoGraph() {
        Intent intent = new Intent(this, PhotoGraphActivity.class);
        intent.putExtra("photoSelectedComplete", 100);
        intent.putExtra("max", 20);
        intent.putExtra("cacheNameCode", cacheNameCode);
        startActivity(intent);
    }
}